package com.deyuanyun.pic.insp.controller.statistics;

import com.deyuanyun.pic.common.util.ajax.AjaxSupport;
import com.deyuanyun.pic.settings.controller.AbstractBaseController;
import com.deyuanyun.pic.settings.domain.base.Code;
import com.deyuanyun.pic.settings.domain.pipe.PipeLine;
import com.deyuanyun.pic.insp.service.statistics.InspStatService;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

/**
 * 金属损失统计
 * @author 王敏
 *
 */
@Controller
@RequestMapping("/insp/statistics/metallossStat")
public class InspStatController extends AbstractBaseController {

	@Resource
	InspStatService inspStatService;
	
	@RequestMapping("/page.html")
	public ModelAndView toPage(){
		ModelAndView mav=new ModelAndView("/insp/statistics/matalossStat");
		//查询管道名称 
		List<PipeLine> lineList=lineService.getLine();
		mav.addObject("lineList", lineList);
		List<Code> data= CodeUtil.getCodeList("METALOSS_TYPE");
		for(Code c:data)
		{
			if(c.getMinorCode()!=null && c.getId() != null){
				mav.addObject(c.getMinorCode(), c.getId());
			}
			
		}
		
		return mav;
	}
	
	@RequestMapping("/search.json")
	public void search(@RequestParam HashMap<String, Object> param,
			           HttpServletResponse response){
		AjaxSupport.sendSuccessText("ok", inspStatService.findData(param));
	}
}
